#include <bits/stdc++.h>
using namespace std;
int n,m,mp[5100][5100],dp[5100],sb[5010],nb[5010];
int dfs(int cur){
    if(dp[cur]!=-1)return dp[cur];
    if(!nb[cur])return 1;
    int sum =0;
    for(int i=1;i<=n;i++){
        if(mp[i][cur]){
            sum = (sum+dfs(i))%80112002;
        }
    }
    dp[cur]=sum;
    return dp[cur];
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=m;i++){
            int t1,t2;
            cin>>t1>>t2;
            mp[t1][t2]=1;
            sb[t1]=1;
            nb[t2]=1;
    }
    memset(dp,-1,sizeof(dp));
    int ans;
    for(int i=1;i<=n;i++){
        if(!sb[i])
        ans = (ans+dfs(i))%80112002;
    }
    cout<<ans;
    return 0;
}
